package day10;

import java.io.*;
import java.net.Socket;

/**
 * @author oldliu
 * @since 1.0
 */
public class FileGetClient {
    public static void main(String[] args) {
        try {
            Socket s=new Socket("localhost",8888);
            InputStream in = s.getInputStream();
            OutputStream out = s.getOutputStream();
//            out.write("yuenan.jpg\r\n".getBytes());
//            out.flush();
            PrintWriter pw=new PrintWriter(out,true);
            pw.println("yuenan.jpg");
            //
            byte []b=new byte[1024];
            System.out.println(in.available()+" ? avaiable");
            FileOutputStream fout=new FileOutputStream("E:/yuenan.jpg");
            int len=0;
            while((len=in.read(b))!=-1){
                fout.write(b,0,len);
            }
            fout.close();
            s.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
